﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BattleThis.Core.Battle;
using BattleThis.Core.Movement;

namespace BattleThis.Core
{
	/// <summary>
	/// Abstact Unit.
	/// </summary>
	[System.Diagnostics.DebuggerDisplay("Unit {Id}")]
	public class Unit
	{

		#region Variablen
		/// <summary>
		/// Defines a Empty Unit.
		/// </summary>
		public static readonly Unit Empty = new Unit();
		#endregion

		#region Properties

		/// <summary>
		/// Gets or sets the id of the unit.
		/// </summary>
		/// <value>
		/// The id.
		/// </value>
		public int Id { get; protected set; }

		/// <summary>
		/// Gets the type.
		/// </summary>
		public UnitType Type { get; protected set; }

		/// <summary>
		/// Gets or sets the armored of the unit.
		/// </summary>
		/// <value>
		/// The armored.
		/// </value>
		public Armor Armor { get; set; }

		/// <summary>
		/// Gets or sets the experience of the unit.
		/// </summary>
		/// <value>
		/// The experience.
		/// </value>
		public Experience Experience { get; set; }

		/// <summary>
		/// Gets or sets the movement points of the unit.
		/// </summary>
		/// <value>
		/// The movement points.
		/// </value>
		public ActionPoint ActionPoints { get; set; }

		/// <summary>
		/// Gets or sets the attack points.
		/// </summary>
		/// <value>
		/// The attack points.
		/// </value>
		public Weapon Weapon { get; set; }

		/// <summary>
		/// Gets or sets the balance.
		/// </summary>
		/// <value>
		/// The balance.
		/// </value>
		public Balance Balance { get; set; }

		#endregion

		#region Methoden
		/// <summary>
		/// Initializes a new instance of the <see cref="Unit"/> class.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="type">The type.</param>
		public Unit( int id , UnitType type )
		{
			//todo hulk find a framework for using expression to be refactoring save Ensure.NotN

			this.Id  = id;
			this.Type = type;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="Unit"/> class.
		/// </summary>
		protected Unit()
		{
			this.Id = -1;
			this.Type = UnitType.None;
			this.Armor = Armor.Empty;
			this.Balance = Balance.Empty;
			this.Weapon = Weapon.Empty;
			this.Experience = new Experience();
			this.ActionPoints = ActionPoint.Empty;
		}

		/// <summary>
		/// Determines whether this instance is empty.
		/// </summary>
		/// <returns>
		///   <c>true</c> if this instance is empty; otherwise, <c>false</c>.
		/// </returns>
		public bool IsEmpty()
		{
			return this.Equals( Unit.Empty );
		}

		/// <summary>
		/// Returns a <see cref="System.String"/> that represents this instance.
		/// </summary>
		/// <returns>
		/// A <see cref="System.String"/> that represents this instance.
		/// </returns>
		public override string ToString()
		{
			return this.Type.ToString();
		}

		#endregion

	}

}